package com.kingdee.eas.wzgzw.base.app;

import org.apache.log4j.Logger;
import javax.ejb.*;
import java.rmi.RemoteException;
import com.kingdee.bos.*;
import com.kingdee.bos.util.BOSObjectType;
import com.kingdee.bos.metadata.IMetaDataPK;
import com.kingdee.bos.metadata.rule.RuleExecutor;
import com.kingdee.bos.metadata.MetaDataPK;
//import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.bos.framework.ejb.AbstractEntityControllerBean;
import com.kingdee.bos.framework.ejb.AbstractBizControllerBean;
//import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.bos.dao.IObjectValue;
import com.kingdee.bos.dao.IObjectCollection;
import com.kingdee.bos.service.ServiceContext;
import com.kingdee.bos.service.IServiceContext;

import java.lang.String;

import com.kingdee.eas.util.client.MsgBox;
import com.kingdee.eas.wzgzw.base.ProRegistrationCollection;
import com.kingdee.eas.wzgzw.base.ProRegistrationFactory;
import com.kingdee.eas.wzgzw.base.ProRegistrationInfo;
import com.kingdee.eas.wzgzw.base.ProRegistrationTreeCollection;
import com.kingdee.eas.framework.app.TreeBaseControllerBean;
import com.kingdee.bos.metadata.entity.EntityViewInfo;
import com.kingdee.eas.basedata.assistant.AssistantCtrlUnitUtils;
import com.kingdee.eas.common.EASBizException;
import com.kingdee.eas.common.client.OprtState;
import com.kingdee.bos.dao.IObjectPK;
import com.kingdee.eas.wzgzw.base.ProRegistrationTreeInfo;
import com.kingdee.bos.metadata.entity.SelectorItemCollection;
import com.kingdee.eas.framework.CoreBaseCollection;
import com.kingdee.eas.framework.TreeBaseCollection;
import com.kingdee.eas.framework.CoreBaseInfo;
import com.kingdee.eas.framework.ObjectBaseCollection;
import com.kingdee.eas.framework.DataBaseCollection;

public class ProRegistrationTreeControllerBean extends AbstractProRegistrationTreeControllerBean
{
    private static Logger logger =
        Logger.getLogger("com.kingdee.eas.wzgzw.base.app.ProRegistrationTreeControllerBean");
    protected void addnewCheck(Context ctx, IObjectValue model)
    throws BOSException, EASBizException
  {
    ((ProRegistrationTreeInfo)model).setCU(AssistantCtrlUnitUtils.getRootCU(ctx));
    _checkNumberBlank(ctx, model);
    _checkNameBlank(ctx, model);
   _checkNameDup(ctx, model);
    _checkNumberDup(ctx, model);
  }

  protected IObjectPK _addnew(Context ctx, IObjectValue model)
    throws BOSException, EASBizException
  {
    addnewCheck(ctx, model);
    return super._addnew(ctx, model);
  }

  protected void _addnew(Context ctx, IObjectPK pk, IObjectValue model)
    throws BOSException, EASBizException
  {
    addnewCheck(ctx, model);
    super._addnew(ctx, pk, model);
  }

  protected void updateCheck(Context ctx, IObjectPK pk, IObjectValue model)
    throws BOSException, EASBizException
  {
    _checkNumberBlank(ctx, model);
    _checkNameBlank(ctx, model);
    ProRegistrationTreeInfo oldModel = getProRegistrationTreeInfo(ctx, pk);
    if (!((ProRegistrationTreeInfo)model).getNumber().equals(oldModel.getNumber()))
    {
      _checkNumberDup(ctx, model);
    }

    if (!((ProRegistrationTreeInfo)model).getName().equals(oldModel.getName()))
    {
      _checkNameDup(ctx, model);
    }
  }
	public void delete(Context ctx, IObjectPK pk) throws BOSException,
			EASBizException {
		
		super.delete(ctx, pk);
	}

  protected void _update(Context ctx, IObjectPK pk, IObjectValue model)
    throws BOSException, EASBizException
  {
    updateCheck(ctx, pk, model);
    super._update(ctx, pk, model);
  }
}